/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.database;
  
import java.sql.ResultSet; 
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import model.entities.Account;

/**
 *
 * @author HoangTien
 */
public class SqlAccount {

    MyConnection mc = new MyConnection();

    public Account getAccount(String uname) {
        Account account = null;
        List para = new ArrayList();
        para.add(uname);
SqlFolder sqlFolder = new SqlFolder();
        try {
            ResultSet rs = mc.executeQuery("sp_get_account_by_uname", para);
            if (rs.next()) {
                account = new Account();
                account.setUsername(rs.getString(1));
                account.setPassword(rs.getString(2));
                account.setFullname(rs.getString(3));
                account.setRoles(rs.getString(4));
                //List<Folder> listfd = ;
                account.setListFolders(sqlFolder.getListFolder(account)); 
            }
        } catch (SQLException ex) {
            System.out.println(ex);
        } 
        return account;
    }
}
